package net.newsmth.smthapp.android.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import net.newsmth.smthapp.android.ui.HotFragment;
import net.newsmth.smthapp.android.ui.TextTestFragment;

/**
 * Created by Hatsune Miku on 3/19/14.
 */
public class MainPagerAdapter extends FragmentPagerAdapter {
    private String[] tabNames;

    public String[] getTabNames() {
        return tabNames;
    }

    public void setTabNames(String[] tabNames) {
        this.tabNames = tabNames;
    }

    public MainPagerAdapter(FragmentManager fm) {
        super(fm);
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return tabNames[position];
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0)
        {
            HotFragment fragment = new HotFragment();
            Bundle args = new Bundle();
            args.putInt(HotFragment.EXPANDED_GROUP_KEY, 0);
            fragment.setArguments(args);

            return fragment;

        } else {
            return TextTestFragment.newInstance(position);
        }
    }

    @Override
    public int getCount() {
        return tabNames.length;
    }
}
